﻿module CodeCamp01.Tags
{
  import CodeCamp01.BasicTypes;
  import CodeCamp01.Events;
  import CodeCamp01.Contents;
    
  // types
    
  type EventFreeTag
  {
    Id : Integer32 => AutoNumber();
    Name : Text128;
  }
    
  type Tag : EventFreeTag
  {
    EventId : Event where value in Events;
  }
    
  type SessionTag
  {
    Id : Integer32 => AutoNumber();
    SessionId : Session where value in Sessions;
    TagId : Tag where value in Tags;
  }
    
  // extents
  
  Tags : { Tag* } where
    identity Id,
    unique( EventId, Name );
  
  SessionTags : { SessionTag* } where
    identity Id,
    unique( SessionId, TagId );

  BannedTags : { EventFreeTag* } where
    identity Id,
    unique Name;
}
